package com.wn.ticket.common;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author wuqingting
 * @date 2022/8/2
 */
@Getter
@Setter
public class ResponseEntity<T> {
    private String code;
    private String msg;
    private T data;
    public static final ResponseEntity success=new ResponseEntity<>("200","ok",null);//正常
    public static final ResponseEntity fail=new ResponseEntity<>("400","fail",null);//统一异常处理捕获到的但类型不明确的异常
    public static final ResponseEntity noPermission=new ResponseEntity<>("402","noPermission",null);//权限不足
    public static final ResponseEntity tokenFail=new ResponseEntity<>("701", "token验证失败", null);//token验证失败
    public static final ResponseEntity tokenOverTime=new ResponseEntity<>("702", "token超时", null);//token超时
    public static final ResponseEntity ParameterException=new ResponseEntity<>("600", "参数错误", null);//参数校验问题,此处为错误编码实例,实际校验参数异常时应使用构造方法new ResponseEntity("600", "参数错误", 错误的参数信息)带上错误信息

    public ResponseEntity(T data) {
        this.code = "200";
        this.msg = "ok";
        this.data = data;
    }

    public ResponseEntity(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

}
